{template header}
<style type="text/css">
    .popup {
        background-color: whitesmoke;
        display: none;
        padding: 10px;
        border: 2px solid #ddd;
        position: fixed;
        top: 50%;
        left: 50%;
        width:250px;
        height:250px;
        z-index: 99999;
    }
    .bg{display:none;position:fixed;width:100%;height:100%;background:#000;z-index:2;top:0;left:0;opacity:0.7;}
</style>
<h4 style="padding-left:10px;;">
    <span>搜索</span>
    <i class="icon-search"></i>
</h4>
<form class="form-horizontal" method="post" action="">
    <div class="control-group search-group" style="margin:0;">
        <label class="control-label" >状态：</label>
        <div class="controls">
            <select name="status">
                <option value="-1">全部</option>
                {loop $status $k $v}
                <option value="{$k}" {if $s==$k}selected{/if}>{$v}</option>
                {/loop}
            </select>
        </div>
    </div>
    <div class="control-group search-group" style="margin:0;">
        <div class="controls">
            <button class="btn" type="submit">提交</button>
            <!-- <button class="btn" type="reset">重置</button> -->
        </div>
    </div>
</form>
<div class="bs-docs-example table-align pt-15" style="clear:both;">
    <table class="table table-striped table-align">
        <thead>
        <tr>
            <th>群名称</th>
            <th>群人数</th>
            <th>群活动数</th>
            <th>申请人姓名</th>
            <th>手机号</th>
            <th>申请说明</th>
            <th>身份证信息</th>
            <th>申请时间</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {loop $info $k $v}
            <tr>
                <td><a href="?c=admin&a=GroupStatistic&gid={$v['gid']}">{$v['name']}</a></td>
                <td>{$v['members']}</td>
                <td><a href="?c=admin&a=groupActList&gid={$v['gid']}">{$v['actNum']}</a></td>
                <td>{$v['realname']}</td>
                <td>{$v['phone']}</td>
                <td>{$v['info']}</td>
                <td><p>{if isset($v['img'][0])}<a href="{$v['img'][0]}" target="_blank" title="点击查看"><img style="width: 150px;height: 80px" src="{$v['img'][0]}"/></a>{/if}
                    {if isset($v['img'][1])}<a href="{$v['img'][1]}" target="_blank" title="点击查看"><img style="width: 150px;height: 80px" src="{$v['img'][1]}"/></a>{/if}</p>
                </td>
                <td>{eval echo date("Y-m-d H:i:s",$v['add_time'])}</td>
                <td>{$v['sName']}</td>
                <td>
                    {if $v['status'] == 0}
                        <button class="btn btn-primary" onclick="handle({$v['id']},'pass')">通过</button>&nbsp;&nbsp;
                        <button class="btn btn-primary" name="{$v['id']}" onclick="layer(this,'refuse')">拒绝</button>
                    {/if}
                    {if $v['status'] == 1}
                    <button class="btn btn-primary" name="{$v['id']}" onclick="layer(this,'cancel')">取消</button>&nbsp;&nbsp;
                    {/if}
                </td>
                <td>
                    <div class="bg" id="bg_{$v['id']}"></div>
                    <div class="popup" id="popup_{$v['id']}">
                        <textarea style="width:235px;height: 200px" id="reason_{$v['id']}"></textarea>
                        <div style="text-align: center">
                            <button class="btn btn-primary" onclick="handle({$v['id']})">确定</button>&nbsp;&nbsp;
                            <button class="btn btn-primary" onclick="$('.popup').hide();$('.bg').hide()">取消</button>
                        </div>
                    </div>
                </td>
            </tr>

        {/loop}
        <div id="res"></div>
        </tbody>
    </table>

</div>
<div class="pagination">
    <ul>
        {$pageStr}
    </ul>
</div>
{template footer}
<script>
    var act = 'cancel';
    function layer(obj,actName) {
        var id = $(obj).attr('name');
        $("#bg_"+id).show();
        $("#popup_"+id).fadeIn(300);
        act = actName;
        var popMargTop = $("#popup_"+id).height() / 2;
        var popMargLeft = $("#popup_"+id).width() / 2;
        $("#popup_"+id).css({
            'margin-top' : -popMargTop,
            'margin-left' : -popMargLeft
        });
    };
    function handle(id,action){
        if(action != undefined){
            act = action;
        }
        var reason = $("#reason_"+id).val();
        var reqData = {id:id,act:act,reason:reason};
        $.post('?c=admin&a=auth',reqData,function(data){
            alert(data.msg);
            if(data.code==200) window.location.reload();
        },"json")
    }
</script>
